wordpress获取热门文章的功能代码:global $wpdb;
$today = date("Y-m-d H:i:s"); //获取今天日期时间
$daysago = date( "Y-m-d H:i:s", strtotime($today) - ($days * 24 * 60 * 60) );
$sql = "SELECT comment_count,ID,post_title ";
$sql .= "FROM $wpdb->posts where post_status='publish' and post_type='post' ";
$sql .= " and post_date BETWEEN '$daysago' AND '$today' ";
$sql .= "ORDER BY comment_count DESC ";
$sql .= "LIMIT 0 , $num";
$hotposts = $wpdb->get_results($sql);
知识技术
0
0
0